﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>客商信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/Content/Scripts/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/layui/layui.js"></script>

</head>
<body>
    <div class="layui-fluid"> @*style="margin:5px"*@
        <div style="float:left">
            <div id="treeNav" class="demo-tree demo-tree-box" style="width: 200px; height: 90%; overflow: scroll;float:left;"></div>

        </div>
        <div style="float:left;width:76%;margin-left:3px">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                        @*<div class="layui-inline layui-show-xs-block">
                            <input type="text" name="id" placeholder="ID" autocomplete="off" class="layui-input" id="id">
                        </div>*@
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="cuCode" placeholder="检索编码" autocomplete="off" class="layui-input" id="cuCode">
                        </div>
                        <div class="layui-inline layui-show-xs-block">

                            <input type="text" name="cuName" placeholder="检索名称" autocomplete="off" class="layui-input" id="cuName">
                        </div>
                        <input type="hidden" id="cuType" name="cuType" />
                        <input type="hidden" id="dataType" name="dataType" />
                        <input type="hidden" id="status" name="Y" />
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData('')"><i class="layui-icon">&#xe615;</i></button>
                            <button class="layui-btn" lay-filter="sreach" id="btnSure" type="button" onclick="Confirm()"><i class="layui-icon">&#xe679;</i>确认</button>
                        </div>
                    </form>
                </div>


                <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                    <table class="layui-hide" id="list" lay-filter="list"></table>
                </div>
            </div>


        </div>
    </div>
</body>

</html>

<script>
    var currPage = 1
    var cData = new Array();
    /**
    加载数据
    **/
    function loadData(typeCode) {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            dUrl = "../Basis/GetDataList?condition=" + conditon + "&dataType=" + dataType;
            table.render({
                elem: '#list'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { type: 'checkbox' }
                    , { field: 'id', align: 'center', title: 'ID', width: '5%' }
                    , { field: 'cuCode', align: 'center', title: '编码', width: '20%' }
                    , { field: 'cuName', align: 'center',title: '名称', width: '32%' }
                    , { field: 'arddress', align: 'center', title: '地址', width:'40%' }
                   
                ]], done: function (res, curr, count) {
                    $("[data-field='id']").css('display', 'none');//隐藏列
            
                }
                , url: dUrl
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 30, 50]
                , limit: 15 //每页默认显示的数量
               
            });

            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;
                var checkStatus = table.checkStatus('list');
                var select = new Array();
                for (var i = 0; i < checkStatus.data.length; i++) {
                    select.push(checkStatus.data[i]);
                }
                cData = select;
            });

        });
    }
    var dataType = "";
    var single = "1";
    $(function () {
        //获取列表
        dataType = getUrlVariable("dataType");
        single = getUrlVariable("isSingle");
        $("input[ name='dataType']").val(dataType);
        Navigation();
    })


    function Navigation() {
        $.ajax({
            url: "../Basis/CuClassNavigation",
            data: { dataType: dataType },
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.Result) {
                    loadTree(data.Data);
                } else {
                    layer.msg(data.Message);
                }
            }
        });
    }

    var typeCode = ''
    var inventory = ''

    function loadTree(data) {
        var tree = layui.tree;
        var layer = layui.layer;
        var util = layui.util;
        //开启节点操作图标
        tree.render({
            elem: '#treeNav'
            , data: data
            , click: function (obj) {
                //console.log(obj.data)
                typeCode = obj.data["id"];
                inventory = obj.data["title"];
                $("input[ name='cuType']").val(obj.data["id"]);
                loadData();
            }
        });
    }
    /**
    确认选择
    **/
    function Confirm() {
        if (cData.length < 1) {
            layer.msg("您没有选择任何数据"); return;
        } else {
            if (single == "1" && cData.length > 1) {
                layer.msg("请选择一条数据"); return;
            } else {
                parent.getCustomPar(cData); //这是父页面函数
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        }
    }
</script>
